package com.lytxmd.boxtest.ui.main;

import com.lytxmd.boxtest.bean.DeviceInfo;
import com.lytxmd.boxtest.http.CallbackTemplate;
import com.lytxmd.boxtest.utils.SPUtils;

/**
 * Created by zhangyinglong on 2017/5/16.
 */
public class MainPresenterImpl extends MainContract.MainPresenter{
    private MainContract.MainView view;
    private MainContract.MainModel model;
    public MainPresenterImpl(MainContract.MainView view){
        this.view = view;
        model = new MainModelImpl();
    }

    @Override
    void getDeviceInfo(String deviceNumStr) {
        SPUtils.putSP(view.getActivity(),"deviceNumber",deviceNumStr);
        model.getDeviceInfo(deviceNumStr).execute(new CallbackTemplate<DeviceInfo>(view.getActivity()){
            @Override
            public void success(DeviceInfo deviceInfo) {
                view.getDeviceInfoSucc(deviceInfo);
            }

            @Override
            public void error(String msg) {
                view.getDeviceInfoFail(msg);
            }
        });
    }

}
